#include "ai_talk_diagnosis.h"

#include <algorithm>
#include <future>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>

#include "utils_file_ex.h"
#include "utils_string_ex.h"
#include "utils_log.h"
#include "common_shell.h"

#include "ai_talk_impl.h"

namespace El {
namespace AITalk {

AITalkDiagnosis &AITalkDiagnosis::GetInstance()
{
    static AITalkDiagnosis instance;
    return instance;
}

bool AITalkDiagnosis::Start()
{
    Common::Shell::GetInstance().RegisterCommand(
        "talk", std::bind(&AITalkDiagnosis::Talk, this, std::placeholders::_1));
    return true;
}

void AITalkDiagnosis::Talk(const std::string &args)
{
    std::vector<std::string> vec_args;
    Utils::Split(args, " ", vec_args);
    if (vec_args.size() < 1) {
        EL_ERROR("Invalid args: {}", args.c_str());
        return;
    }

    std::string text = "";
    if (vec_args[0] == "r") {
        AITalkImpl::GetInstance().SendStartListening(ListeningMode::kManualStop);
    }
}

} // namespace AITalk
} // namespace El